The Geometric Pen
The contours of framed geometric shapes are drawn with the QuickDraw GX geometric pen. You can specify the width of this pen using the pen width property of the style object, and you can specify where to place the pen relative to the contours of a shape using the style attributes, which are described in "Style Attributes" beginning on page 3-17.Conceptually, the QuickDraw GX geometric pen is a line that QuickDraw GX drags along the contours of the shape being drawn--always keeping it perpendicular to the contours. In effect, the geometric pen turns a framed geometry into a filled one. For example, a line shape, which is always framed, becomes the equivalent of a filled polygon after QuickDraw GX applies the geometric pen.
Figure 3-5 shows the effect of the geometric pen. This figure shows two geometries-- a line geometry and a curve geometry--and how QuickDraw GX draws them with a pen width of 15.
Figure 3-5 The QuickDraw GX geometric pen
Notice that the ends of the thick line contour and the thick curve contour in Figure 3-5 are perpendicular to the direction of the contours themselves.
Figure 3-6 shows the effect of different pen widths on a semicircular path shape.
Figure 3-6 Differing pen widths[Missing image]
Setting a value of 0 for the pen width property has special meaning. Instead of indicating an infinitely thin pen, it indicates that a shape's contours should be drawn using hairlines--the thinnest line renderable on the device to which the shape is drawn. A hairline is always one pixel wide and is always centered about the shape's geometry.
One important use of hairlines is to make point shapes visible. QuickDraw GX draws point shapes under only two conditions: if the pen width is 0, indicating a hairline point, in which case exactly one pixel is drawn, or if the point has a start cap, which is described in "Caps" beginning on page 3-23.
When drawing a hairline, QuickDraw GX uses this algorithm to determine which pixels to include:
Figure 3-7 depicts this algorithm.
- If the contour being drawn is more vertical than horizontal, QuickDraw GX includes a pixel if the contour crosses the horizontal center line of the pixel.
- If the contour being drawn is more horizontal than vertical, QuickDraw GX includes a pixel if the contour crosses the vertical center line of the pixel.
Figure 3-7 Pixels included in a hairline
In extreme cases, this algorithm can cause no pixels to draw, as shown in Figure 3-8.
Figure 3-8 A geometry with no hairline
The section "Manipulating Pen Width and Placement" on page 3-51 gives an example of using the pen width property, and the section "Getting and Setting the Pen Width" on page 3-119 describes the functions you can use to manipulate it.
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help